﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Nova_DAL;
using System.Data.Common;
using Nova_Common;

public partial class System_User_UserEdit : System.Web.UI.Page
{
    DbCommand cmd = null;
    Nova_DAL.DbHelper access = new DbHelper();
    string strSQL = "";
    DataSet ds = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        

        if (!IsPostBack)
        { 
        }

    }

    protected void ibtnOK_Click(object sender, ImageClickEventArgs e)
    {
        HttpCookie Cookies = Request.Cookies["vNovaUserNo"];

        strSQL = "SELECT * FROM tbUser WHERE vUserNo='" + Cookies.Value.ToString() + "' and vPassWord = '" + txtOldPassWord.Text.ToString() + "'";
        cmd = access.GetSqlStringCommond(strSQL);
        ds = access.ExecuteDataSet(cmd);
        if (ds.Tables[0].Rows.Count > 0)
        {
            if (txtNewPassWord.Text.ToString() != txtPassWord.Text.ToString())
            {
                ShowBox.MessageBox(this.Page, "新密码两次输入不一样！");
                return;
            }
            else
            {
                strSQL = "Update tbUser set vPassWord = '" + txtNewPassWord.Text.ToString() + "' where vUserNo='" + Cookies.Value.ToString() + "'";
                cmd = access.GetSqlStringCommond(strSQL);
                int i = access.ExecuteNonQuery(cmd);
                if (i > 0)
                {
                    ShowBox.MessageBox(this.Page, "修改成功！");
                    return;
                }
                else
                {
                    ShowBox.MessageBox(this.Page, "修改失败！");
                    return;
                }
            }
        }
        else
        {
            ShowBox.MessageBox(this.Page, "对不起，旧密码不对！");
            return;
        }

    }
}
